#include <cmath>
#include <iostream>
using namespace std;
double triangleArea(const double* parray);

int main()
{
    cout << "Please give three sides: ";
    
    double sides[3]{};
    for (int i = 0; i < 3; i++)
    {
        cin >> sides[i];
    }
    double area = triangleArea(sides);

    cout << "The area is:"<<area;
}

double triangleArea(const double* parray)
{
    // 解引用指针获取边长  
    double a = parray[0];
    double b = parray[1];
    double c = parray[2];

    // 使用海伦公式计算面积  
    double s = (a + b + c) / 2;
    double area = sqrt(s * (s - a) * (s - b) * (s - c));

    // 如果输入的边长不能构成三角形，则返回-1表示错误  
    if (area < 0) {
        cout << "The given sides do not form a valid triangle." ;
        return -1;
    }

    return area;
}
